package com.spareparts.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

import com.spareparts.R;
import com.spareparts.activity.base.BaseActivity;
import com.spareparts.entyties.WuLiao;

public class SearchDetailActivity extends BaseActivity {
	private EditText edQuYu;
	private EditText edJuDian;
	private EditText edKuFang;
	private EditText edWuLiao;
	private EditText edMiaoShu;
	private EditText edShuliang;
	private EditText edChanPinXian;
	private EditText edShouJianRen;
	private EditText edDianHua;

	private Button btSave;
	private Button btDel;
	private Button ButtonYes;
	public static final String wuliaoKey = "wuliao";
	private WuLiao wuLiao;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_search_detail);
		edQuYu = (EditText) findViewById(R.id.editText_quyu);
		edJuDian = (EditText) findViewById(R.id.editText_judian);
		edKuFang = (EditText) findViewById(R.id.editText_kufang);
		edWuLiao = (EditText) findViewById(R.id.editText_wuliao);
		edMiaoShu = (EditText) findViewById(R.id.veneercodesEditText);
		edShuliang = (EditText) findViewById(R.id.editText_shuliang);
		edChanPinXian = (EditText) findViewById(R.id.editText_chanpinxian);
		edShouJianRen = (EditText) findViewById(R.id.editText_shoujianren);
		edDianHua = (EditText) findViewById(R.id.editText_phone);
		ButtonYes = (Button) findViewById(R.id.button_yes);
		if (getIntent() != null && getIntent().hasExtra(wuliaoKey)) {
			wuLiao = (WuLiao) getIntent().getSerializableExtra(wuliaoKey);
			showDataWithWuliao(wuLiao);
		}
		ButtonYes.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	/**
	 * 根据物料对象，展示物料
	 * 
	 * @param wuLiao
	 */
	private void showDataWithWuliao(WuLiao wuLiao) {
		if (wuLiao == null) {
			return;
		}
		edQuYu.setText(wuLiao.warehouse.rid);
		edJuDian.setText(wuLiao.warehouse.pointname);
		edKuFang.setText(wuLiao.warehouse.name);
		edWuLiao.setText(wuLiao.sparetype.code);
		edMiaoShu.setText(wuLiao.sparetype.descrption);
		edShuliang.setText(wuLiao.number);
		edChanPinXian.setText(wuLiao.sparetype.productline);
		edShouJianRen.setText(wuLiao.warehouse.headman);
		edDianHua.setText(wuLiao.warehouse.contact);
	}
}
